# --*-- coding:utf8 --*--
import os
import pyecharts.options as opts
from pyecharts.charts import Pie
from tools.path import cur_path

CURPATH = cur_path()


def myPie(data, name):
    (
        # Pie(init_opts=opts.InitOpts(width="1600px", height="800px"))
        Pie(init_opts=opts.InitOpts(width="1340px", height="555px"))
        # Pie(init_opts=opts.InitOpts(width="800px", height="400px"))
            .add(
            series_name=name,
            data_pair=data[0],
            radius=[0, "15%"],
            label_opts=opts.LabelOpts(
                position="inner"
                # position="middle",
            ),
        )
            .add(
            series_name=name,
            radius=["25%", "40%"],
            data_pair=data[1],
            label_opts=opts.LabelOpts(
                # position="middle",
                position="inner",
                is_show=False
            )
        )
            .add(
            series_name=name,
            radius=["50%", "80%"],
            data_pair=data[2],
            label_opts=opts.LabelOpts(
            position="inner",
            is_show=False
            )
        )
            .set_global_opts(
            legend_opts=opts.LegendOpts(is_show=False)
            # legend_opts=opts.LegendOpts(pos_left="left", orient="vertical")
            # legend_opts = opts.LegendOpts(pos_left="1%", pos_top="10%", orient="vertical")
        )
        .render(os.path.join(CURPATH, "饼图-%s.html" % name))
    )
